import requests

from Hmshop_api import HmshopLoginApi
from assert_tools import common_assert


class TestHmshopLogin(object):
    session = None

    def setup_method(self):
        self.session = requests.session()
        HmshopLoginApi.get_verifyCode(self.session)

    def test01_login_success(self):
        login_data = {"username": "13800000002", "password": "123456", "verify_code": "8888"}
        response = HmshopLoginApi.login(self.session, login_data)
        print("登录成功：", response.json())
        common_assert(response, 200, 1, "登陆成功")

    def test02_username_not_exist(self):
        login_data = {"username": "13812341234", "password": "123456", "verify_code": "8888"}
        response = HmshopLoginApi.login(self.session, login_data)
        print("手机号未注册：", response.json())
        common_assert(response, 200, -1, "账号不存在!")

    def test03_pwd_error(self):
        login_data = {"username": "13800000002", "password": "12345678", "verify_code": "8888"}
        response = HmshopLoginApi.login(self.session, login_data)
        print("密码错误：", response.json())
        common_assert(response, 200, -2, "密码错误!")
